//
//  Tool.h
//  就到
//
//  Created by MT on 2017/11/13.
//  Copyright © 2017年 MT. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CommonCrypto/CommonDigest.h>

#define USER_DEFAULT    [NSUserDefaults standardUserDefaults]

extern NSString* const kBaseURLKey;

/*
 电话当前网络类型
 */
typedef enum{
    PNT_UNKOWN          =0, //未知，无网络
    PNT_WIFI            =1, //WIFI
    PNT_2G3G                //2G/3G
    
}PhoneNetType;
@interface Tool : NSObject

/*
 设置本地数据库key对应的数据
 */
+ (void)setLocalDataValue: (NSString *)aValue key:(NSString *)aKey;
/*
 读取本地数据库的Value
 */
+ (id)getLocalDataValue:(NSString *)aKey;
/*
 设置本地数据库key对应的bool数据
 */
+ (void)setLocalDataBoolen: (BOOL)aValue key:(NSString *)aKey;
/*
 获取本地数据库对应的bool数据
 */
+ (BOOL)getLocalDataBoolen: (NSString *)aKey;
/*
 设置本地数据库key对应的array数据
 */
+ (void)setLocalDataArray: (NSMutableArray *)array key:(NSString *)aKey;
/*
 获取本地数据库对应的array数据
 */
+ (id)getLocalDataArray: (NSString *)aKey;
/*
 设置本地数据库key对应的dictionary数据
 */
+ (void)setLocalDataDictionary: (NSDictionary *)dictionary key:(NSString *)aKey;
/*
 获取本地数据库对应的dic数据
 */
+ (id)getLocalDataDictionary: (NSString *)aKey;
/*
 设置本地数据库key对应的对象数据
 */
+ (void)setLocalDataObject: (NSObject *)Object key:(NSString *)aKey;
/*
 获取本地数据库对应的对象数据
 */
+ (id)getLocalDataObject: (NSString *)aKey;

//对象转json字符串
+ (NSString*)DataTOjsonString:(id)object;

//返回一个安全的字典
+ (NSMutableDictionary *)returnSafeDictionary:(NSDictionary *)dic;

//验证手机号的正则
+ (BOOL) IsPhoneNumber:(NSString *)number;

// 设置密码的位数
+ (BOOL) IsCorrectPassword:(NSString *)phoneStr;

// 正则匹配用户密码6-16位数字和字母组合
+ (BOOL)checkPassword:(NSString *) password;

//获取电话当前网络类型
+ (PhoneNetType)getCurrentPhoneNetType;
+ (NSString *)getNetWorkStates;

//判断字符串是否包含汉字
+ (BOOL)isContainChinese:(NSString *)string;
//判断是否是纯数字
+ (BOOL)isStringPureInt:(NSString *)string;

//计算textvie动态高度
+ (float) heightForString:(NSString *)value fontSize:(float)fontSize andWidth:(float)width;

//计算文字长度
+ (CGFloat )widthForLabel:(NSString *)text fontSize:(CGFloat)font;

//获取磁盘缓存文件大小
+ (float)readCacheSize;
//清除缓存
+ (void)clearFile;

//获取当前viewcontroller
+ (UIViewController *)getCurrentVC;

//正则匹配用户身份证号15或18位
+ (BOOL)checkUserIdCard:(NSString *)idCard;

//字典转json
+ (NSString *)convertToJsonData:(NSDictionary *)dict;

//字典转字符串
+ (NSString*)dictionaryToJson:(NSDictionary *)dic;

//判断字符串是否空
+ (BOOL) isBlankString:(NSString *)string;

//验证银行卡号
+ (BOOL) checkCardNo:(NSString*) cardNo;

//判断银行图标
+ (NSString *) judgeCardImage:(NSString*) cardNo;

//获取当前时间
+ (NSString *)getCurrentTimeWithFormat:(NSString *)format;

//获取当前时间戳
+ (NSString *)currentTimeStr;

//时间戳转时间
+ (NSString *)timestampSwitchTime:(NSInteger)timestamp andFormatter:(NSString *)format;

// 根据图片url获取图片尺寸
+ (CGSize)getImageSizeWithURL:(id)URL;

//剪切图片为正方形
+ (UIImage *)squareImageFromImage:(UIImage *)image scaledToSize:(CGFloat)newSize;

//获取当前present控制器
+ (UIViewController *)getPresentedViewController;

/** 通过行数, 返回更新时间 */
+ (NSString *)updateTimeForRow:(NSString *)str;


//image转化成Base64位
+ (NSString *)imageChangeBase64: (UIImage *)image;


//urlEncode编码
+ (NSString *)urlEncodeStr:(NSString *)input;

//urlEncode解码
+ (NSString *)decoderUrlEncodeStr: (NSString *) input;


//签名排序
+ (NSString *)sortSign:(NSDictionary *)dic;
@end
